package com.zhangfei.function;

import java.util.function.Predicate;

public class PredicateTest {
    private static boolean predicate(String something, Predicate<String> predicate) {
        return predicate.test(something);
    }

    private static boolean andPredicate(String something, Predicate<String> predicate1, Predicate<String> predicate2) {
        return predicate1.and(predicate2).test(something);
    }

    private static boolean orPredicate(String something, Predicate<String> predicate1, Predicate<String> predicate2) {
        return predicate1.or(predicate2).test(something);
    }

    private static boolean negPredicate(String something, Predicate<String> predicate) {
        return predicate.negate().test(something);
    }


    public static void main(String[] args) {
        String something = "舌苔润";
        String something1 = "舌苔苦";

        //lambda表达式
        boolean helalthy = predicate("花斑舌", (String some) -> {
            return something.equals(some);
        });
        System.out.println("舌苔是否正常：" + helalthy);


        //lambda表达式  and
        boolean helalthyAnd = andPredicate("", some -> something.equals(some), some -> something1.equals(some));
        System.out.println("舌苔是否正常and：" + helalthyAnd);

        //lambda表达式  or
        boolean helalthyOr = andPredicate("", some -> something.equals(some), some -> something1.equals(some));
        System.out.println("舌苔是否正常and：" + helalthyOr);


        //lambda表达式 neg
        boolean helalthyNeg = negPredicate("花斑舌", some -> something.equals(some));
        System.out.println("舌苔是否正常：" + helalthyNeg);

    }
}
